//导入Node.js官方提供的http模块
import { createServer } from 'node:http'

//创建Web服务器，接收客户端请求(request)，返回响应消息(response)
const server = createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'application/json' })
  res.end('{code:4000, msg:"login success"}')
})

//启动Web服务器，让它监听8081
server.listen(8081, () => {
  console.log('Listening on Port 8081...');
})
